<%@ page import="java.util.List" %>
<%@ page import="cn.com.entity.Article" %>
<%@ page import="cn.com.controler.User.UserDAO" %>
<%@ page import="cn.com.entity.User" %>
<%@ page import="cn.com.controler.ShowComment.ShowCommentDAO" %>
<%@ page import="cn.com.entity.ShowComment" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/10/4
  Time: 23:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>显示动态</title>
    <style type="text/css" rel="stylesheet">
        .AllContent{
            width: 1000px;
            margin: 0 auto;
            padding-top: 20px;
            box-sizing: border-box;
        }
        .AllContent .list{
            width: 900px;
            background: white;
            margin: 0 auto;
            border: 2px solid #1682c2;
            margin-top: 10px;

        }
        .AllContent .list .art-top{
            width: 100%;
            height: 50px;
            background: #4aa3d6;
        }
        .AllContent .list .art-top .username,.AllContent .list .art-top .fbtime{
            float: left;
        }
        .AllContent .list .art-top .username{
            line-height: 50px;
            font-size: 16px;
            width: 600px;
            padding-left: 20px;
            box-sizing: border-box;

        }
        .AllContent .list .art-top .fbtime{
            height: 22px;
            margin-top: 20px;
        }
        .AllContent .list .art-middle{
            width: 100%;
            box-sizing: border-box;
            border-bottom: 1px solid #1682c2;
        }
        .AllContent .list .art-middle .content-cont{
            width: 100%;
            background: white;
            font: 16px "微软雅黑";
            line-height: 1.5;
            letter-spacing: 1px;
            text-indent: 33px;
            padding: 10px 20px;
            box-sizing: border-box;
        }
        .AllContent .list .art-middle .content-menu{
            width: 200px;
            height: 30px;
            margin-left: 660px;
            line-height: 30px;
            text-align: center;
        }
        .AllContent .list .art-buttom{
            width: 100%;
            box-sizing: border-box;
            border-top: none;
            padding: 20px;
            font: 16px "微软雅黑";
        }
        .AllContent .list .art-buttom .pinglun{
            display: block;
            line-height: 1.5;
            letter-spacing: 1px;
            text-indent: 33px;
            margin-top: 10px;
        }
        button{
            width: 60px;
            height: 30px;
            border: none;
            background: #4aa3d6;
            color: white;
            font-weight: 600;
            cursor: pointer;
        }
        button:hover{
            background: none;
            color: red;
            border: 1px solid #4aa3d6;
        }
    </style>
    <script src="/WebContent/JQuery/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body>
<article class="AllContent">
<%
    List allart = (List)request.getAttribute("allart");
    Article article;
    String username;
    String articleTitle;
    String articleContent;
    String articlePublishTime;
    UserDAO userDAO = new UserDAO();
    //遍历集合
    for (int i = 0; i < allart.size() ; i++) {
        article = (Article) allart.get(i);
        Integer articleUserId = article.getArticleUserId();
        //获得发布者的姓名
        List idselect = userDAO.idselect(articleUserId);
        User user = (User) idselect.get(0);
        username = user.getUsername();
        //获得标题，内容
        articleTitle = article.getArticleTitle();
        articleContent = article.getArticleContent();
        articlePublishTime = article.getArticlePublishTime();
        Integer articleType = article.getArticleType();
        int articleId = article.getArticleId();
%>

    <section class="list">
        <div class="articletype" style="display: none" state="<%=articleType%>"></div>
        <div class="art-top">
            <div class="username">用户名：<%=username%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;标题：<%=articleTitle%></div>
            <div class="fbtime"><%=articlePublishTime%></div>
        </div>
        <div class="art-middle">
            <div class="content-cont">
                <%=articleContent%>
            </div>
        </div>
<%
    ShowCommentDAO showCommentDAO = new ShowCommentDAO();
    List<ShowComment> getallcomm = showCommentDAO.getallcomm(articleId);
    if(getallcomm.size() >0){
        for (int j = 0; j < getallcomm.size(); j++) {
            ShowComment comm = getallcomm.get(j);
%>
        <div class="art-buttom">
                 <span class="pldx">
                     <span><%=comm.getUsername()%></span>&nbsp;评论&nbsp;
                 </span>&nbsp;&nbsp;
            <span class="pltime">
                <%=comm.getCommentTime()%>
            </span><br>
            <span class="pinglun">
                <%=comm.getCommentContent()%>
            </span>
        </div>
        <%
        }
    }else{
        %>
        <div class="art-buttom">
            <span class="pinglun">
                暂无评论
            </span>
        </div>
        <%
    }
        %>

    </section>

<%
    }
%>
</article>
<script>
    $(document).ready(function () {
        $(".articletype[state='1']").parent(".list").css("border","2px solid red").end().next(".art-top").
        css({"background":"red"}).find("div").css({"color":"#fff"},{"font-weight":"600"});
    })
</script>
</body>
</html>